
//
//  LMUserTool.m
//  李明微博
//
//  Created by 张青花 on 15/12/13.
//  Copyright (c) 2015年 李明. All rights reserved.
//

#import "LMUserTool.h"
#import "LMHttpTool.h"
#import "LMUserParam.h"
#import "LMUserResult.h"
#import "LMAccountTool.h"
#import "LMAccount.h"
#import "MJExtension.h"

@implementation LMUserTool

+ (void)unreadWithSucess:(void (^)(LMUserResult *))success failure:(void (^)(NSError *))failure
{
    LMUserParam *param = [LMUserParam param];
    param.uid = [LMAccountTool account].uid;
    
    [LMHttpTool GET:@"https://rm.api.weibo.com/2/remind/unread_count.json" parameters:param.mj_keyValues success:^(id responseObject) {
        
        LMUserResult *result = [LMUserResult mj_objectWithKeyValues:responseObject];
        
        if (success) {
            success(result);
        }
        
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

+ (void)userInfoWithSuccess:(void (^)(CZUser *user))success
                    failure:(void (^)(NSError *error))failure
{
    LMUserParam *param = [LMUserParam param];
    param.uid = [LMAccountTool account].uid;
    
    [LMHttpTool GET:@"https://api.weibo.com/2/users/show.json" parameters:param.mj_keyValues success:^(id responseObject) {
        
        CZUser *result = [CZUser mj_objectWithKeyValues:responseObject];
        
        if (success) {
            success(result);
        }
        
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
    
}

@end
